@extends('layouts.app')

@section('content')
    <div class="main-content">
        <div class="search_inp">
                <table width="100%" border="1" class="table_search">
                    <thead>
                        <tr>
                            <th colspan="7">
                                <span>查询条件</span>
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td width="10%" align="right"><label>颜色：</label></td>
                            <td width="10%">
                                <select name="color_id" class="w150">
                                    <option value="">请选择颜色</option>
                                        @foreach($color as $k=>$v)
                                            <option value="{{$v->id}}">{{$v->name}}</option>
                                        @endforeach
                                </select>
                            </td>
                            <td width="10%" align="right"><label>单位名：</label></td>
                            <td width="10%"><input type="text" class="w150" name="name" placeholder="请输入全名"/></td>
                            <td width="10%" align="right"><label>重点级别：</label></td>
                            <td width="10%">
                                <select name="jibie" class="w150">
                                    <option value="">请选择重点级别</option>
                                    <option value="0">非重点</option>
                                    <option value="1">省级</option>
                                    <option value="2">市级</option>
                                    <option value="3">县级</option>
                                    <option value="4">乡级</option>
                                </select>
                            </td>
                            <td width="10%">
                                <a href="javascript:" class="easyui-linkbutton" data-options="iconCls:'icon-search'" style="width:80px" onclick="doSearch()">查询</a>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <script type="text/javascript">
                function doSearch(){
                        $('#dg4').datagrid('load',{
                            color_id:$("select[name='color_id']").val(),
                            name: $("input[name='name']").val(),
                            org_id: $("select[name='org_id']").val(),
                            jibie: $("select[name='jibie']").val(),
                        });
                    }

            </script>


            <div class="form-all mg_t30">
                    <div id="tb3" style="padding:3px">
                        <a href="javascript:void(0)" class="easyui-linkbutton"  onclick="edit()" plain="true" iconCls='icon-edit'>查看</a>
                        <a href="javascript:void(0)" class="easyui-linkbutton"  onclick="setcolor()" plain="true" iconCls='icon-edit'>设置颜色</a>
                    </div>
                    <table id="dg4" title="单位分色展示" class="easyui-datagrid" style="width:100%;height:650px" toolbar="#tb3"
                            data-options="rownumbers:true,singleSelect:true,pagination:true,pageSize:20,url:'{{url('admin/yanpan/fense')}}',method:'get',toolbar:'#dg4'">
                        <thead>
                            <tr>
                                <th data-options="field:'name'" width="20%" align="center">标题</th>

                                <th data-options="field:'type'" width="20%" align="center">单位类型</th>
                                <th data-options="field:'is_imp'" width="20%" align="center">是否重点</th>

                                <th data-options="field:'updated_at'" width="20%"  align="center">修改时间</th>
                                <th data-options="field:'user_id'" width="20%" align="center">操作人</th>
                                
                            </tr>
                        </thead>
                    </table>
                </div>

    </div>
            <script type="text/javascript">
                function edit(){
            //       var row = $('#dg1').datagrid('getSelected');
                    var parent = $(this).parent().next(".datagrid-view").children("table").attr("id");
                    var index =  $('#'+parent).datagrid('getRowIndex', $('#'+parent).datagrid('getSelected'));
                     if(index <0){
                        alert("提示, 请选中要编辑的行！")
                     }else{
                         console.log(index);
                     }
                     
                }
            </script>



        <!-- 考核新增弹框 -->
        <div id="adbg" class="easyui-window" title="添加" data-options="modal:true,closed:true,iconCls:'icon-save'" style="width:900px;height: auto;max-height:560px;padding:10px;">
       
        </div>


        <div id="dlg" class="easyui-dialog" title="删除" closed="true" style="width:400px;height:200px;line-height:100px;text-align:center;font-size:16px;padding:10px">
            您确定要删除该列表？
        </div>

		<script type="text/javascript" src="{{ URL::asset('/') }}js/weizhi.js"></script>
        <script type="text/javascript">

            function add(){
            	var shuz = fb2();
                $('#adbg').window({
                title: "查看",
                href: "add_color",
                width:shuz[0],
				height:shuz[1],
				top:shuz[2],
				left:shuz[3],
                minimizable:false,
                modal:true,
                closed: false,
                });
            }

            function edit(){
        	var shuz = fb2();
            var row = $('#dg4').datagrid('getSelected');
            if (row) {
                var url = 'view/'+row.id;
                $('#adbg').window({
                    title: "编辑",
                    href: url,
                   	width:shuz[0],
					height:shuz[1],
					top:shuz[2],
					left:shuz[3],
                    minimizable:false,
                    modal:true,
                    closed: false,
                });
            }else {
                $.messager.alert('提示','请选中要编辑的行！');
            }
          }


           function setcolor(){
           	var shuz = fb2();
            var row = $('#dg4').datagrid('getSelected');
            if (row) {
                var url = 'save_color/'+row.id;
                $('#adbg').window({
                    title: "编辑",
                    href: url,
                   	width:shuz[0],
					height:shuz[1],
					top:shuz[2],
					left:shuz[3],
                    minimizable:false,
                    modal:true,
                    closed: false,
                });
            }else {
                $.messager.alert('提示','请选中要编辑的行！');
            }
          }

          


          function cancel(){
            var row = $('#dg4').datagrid('getSelected');
            if (row) {
                $('#dlg').dialog({
                    title: "注销",
                    closed: false,
                    modal:true,
                    top:($(window).height() - 200) * 0.5,
					left:($(window).width() - 400) * 0.5,
                    buttons: [{
                        text: '确定',
                        iconCls: 'icon-ok',
                        handler: zhuxiao
                    }, {
                        text: '取消',
                        iconCls: 'icon-cancel',
                        handler: function () {
                            $('#dlg').dialog('close');
                        }
                    }]
                });
            } else {
                $.messager.alert('提示','请选中要编辑的行！');
            }
        }

        function zhuxiao(){
            $('#dlg').dialog('close');
            var row = $('#dg4').datagrid('getSelected');
            var url = 'del_color/'+row.id;
            $.ajax({
                type: 'get',
                url: url,
                success: function(data){
                    if(data.status == 1){
                        $.messager.alert('信息提示',data.msg,'info');
                      
                        var rowIndex = $('#dg4').datagrid('getRowIndex', row);
                        $('#dg4').datagrid('deleteRow', rowIndex);
                    }else{
                        $.messager.alert('信息提示',data.msg,'info');
                    }
                }
            });
        }


        $("#dg4").datagrid({
            onDblClickRow: function (index, row) {
                edit();
            }
        });


        </script>
    <script>
        $(document).ready(function(){
            var winHeight =  window.screen.height;
            var winWidth = 	window.screen.width;
            if(winWidth == 1024){
                $('#taby').css('height',465+'px');
                $('#taby').find('iframe').css('height',436+'px');
            }else if(winWidth == 1280){
                $('#taby').css('height',465+'px');
                $('#taby').find('iframe').css('height',436+'px');
            }else if(winWidth == 1366){
                $('#taby').css('height',465+'px'); $('#taby').find('iframe').css('min-height',436+'px');
            }else if(winWidth == 1920){
                $('#taby').css('height',625+'px');
                $('#taby').find('iframe').css('min-height',596+'px');
            }else{
                $('#taby').css('height',465+'px');
                $('#taby').find('iframe').css('min-height',436+'px');
            }
        })

        function load_city_data_from_menu($id){
            $('#dg').datagrid('load',{
                city: $id,
            });
            $("input[name='city']").val($id);
            $("input[name='area']").val('');
            $("input[name='org_id']").val('');
        }

        function load_area_data_from_menu($id){
            $('#dg').datagrid('load',{
                area: $id,
            });
            $("input[name='city']").val('');
            $("input[name='area']").val($id);
            $("input[name='org_id']").val('');
        }
        function load_org_data_from_menu($id){
            $('#dg').datagrid('load',{
                org_id: $id,
            });
            $("input[name='city']").val('');
            $("input[name='area']").val('');
            $("input[name='org_id']").val($id);
        }
    </script>

     
@stop



